﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SurveySystem.Core;
using System.Web.Security;

namespace SurveySystem.Web
{
    public partial class Unregister : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.Identity.IsAuthenticated)
                Redirect();
        }

        protected void btnNo_Click(object sender, EventArgs e)
        {
            Redirect();
        }

        protected void btnYes_Click(object sender, EventArgs e)
        {
            UsersBLL.UnregisterUser(User.Identity.Name);
            FormsAuthentication.SignOut();
            Membership.DeleteUser(User.Identity.Name);
            Redirect();
        }

        private void Redirect()
        {
            Response.Redirect("~/Default.aspx");
        }
    }
}
